package com.howells.time.module.discovery.presenter;

import com.howells.time.base.http.HttpURL;
import com.howells.time.base.http.HttpUtils;
import com.howells.time.base.http.JsonCallback;
import com.howells.time.module.discovery.view.DiscoveryView;
import com.orhanobut.logger.Logger;

import java.util.Map;

import okhttp3.Call;

import static com.baidu.platform.comapi.map.e.e;

/**
 * Created by Administrator on 2016.5.11.
 */
public class DiscoveryPresenterImp implements DiscoveryPresenter {

    private DiscoveryView mDiscoveryView;

    public DiscoveryPresenterImp(DiscoveryView mDiscoveryView) {
        this.mDiscoveryView = mDiscoveryView;
    }

    @Override
    public void loadDiscovery(Map info) {
        Logger.d(info);
        HttpUtils.Get(HttpURL.GetBlogApi.toString(), info, new JsonCallback() {
            @Override
            public void onError(Call call, Exception e,int id) {
                Logger.d(e);
                mDiscoveryView.resultMsg("网络错误");
            }

            @Override
            public void onResponse(Map<String, Object> response, int id) {
                if(response.get("message").equals("success")){
                    Logger.d(response.get("data"));
                }else {
                    Logger.d(e);
                    mDiscoveryView.resultMsg(response.toString());
                }
            }
        });
    }
}
